package com.eudon.design_pattern.structural.proxy.dynamic_proxy;

import com.eudon.design_pattern.structural.proxy.OrderCache;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author eudon
 * @description 动态代理打印日志
 * @date 2025/9/1
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class DynamicLogHandler implements InvocationHandler {
    private final Object proxyObject;

    public DynamicLogHandler(Object proxyObject) {
        this.proxyObject = proxyObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("日志打印");
        Object invoke = method.invoke(proxyObject, args);
        System.out.println("日志打印结束");
        return invoke;
    }
}
